<?
header("Cache-control: private");
header("Content-type: text/javascript");

$_set = json_decode( $_POST['set'] );

if( $_set->tool == "kill" ) {
	
	?>

		//<script language="Javascript">	
		$("init").seed([
			tag("font", {style:"font-size:18px"}, "logged out "), "thank you for using our platform.", br
		]);
			
		tm = setTimeout("window.location = 'index.php'", 2400)
	
	<?
	
	unset( $_SESSION['uid'], $DB->uservars );
	exit();
	
} else if( $_set->tool == "update" ) {
	
	$Engine->user_session( 1 );
	$comment = "login session updated";
		
	?>
		dashboard.comment("<?=$comment?>");
	<?
	
	exit();

} else {

	$pass = $Engine->user_authenticate( $_set->user, $_set->pass ); 

}

$el = ($pass)?"[{tpe:'b',cont:'login succesful!'},{tpe:'br'},\"please wait, we're loading you up\"]":"[{tpe:'b',cont:'login failed'},{tpe:'br'},'please reload to try again']";
?>

xhttp.gfx({tpe:"div", attr:{}, update:true, cont:<?=$el;?>}, "<?=$_set->trg ?>", {name:"Highlight", options:{startcolor:"#4a4a4a", endcolor:"#ffffff", restorecolor:"#ffffff", duration:<?=($pass)?3:8 ?>}});
xhttp.redirect("<?=($pass)?"?fresh=lang:".engine_get('lang.master'):"?reset=1" ?>", 1200);